package com.tizona.system;

import java.util.*;

import com.tizona.TarifdConfig;

public class  Tarifd2 extends Tarifd  {


    public Tarifd2(TarifdConfig cfg_) {
        super(cfg_);
    }

    public boolean process() throws Exception {


        Calendar cur_time = Calendar.getInstance();

        if(cfg.process_one_lc>0)
        {


            logger.debug("cfg.process_one_lc" + cfg.process_one_lc);

            if(cfg.currentTime != null) {
                logger.debug("Setting param string CurrentTime");
                cur_time.setTime(cfg.currentTime);
            }

            contractMng.handleStaticContract(cur_time, cfg.process_one_lc);

            raiseEvents();
            return true;
        }

        if (cfg.tpln >0) {
            contractMng.handleAllContracts(cur_time, cfg.tpln);

            return true;
        }

        if(cfg.collocation) {
            logger.debug("about to process Collocation: " + cur_time.getTime().toString());
            
            contractMng.handleCollocationContracts(cur_time);
            
            return true;
        }

        return true;
    }

    public static void main(String args[]) throws Exception {
        Tarifd2 inst = new Tarifd2(new TarifdConfig(args));
        System.exit(inst.process() ? 0 : -1);
    }

}
